import { computed, ref } from 'vue';

export default (props, editData) => {
    const showModel = ref(false);
    const isEdit = ref(false);
    const modelTitle = computed(
        () => `${isEdit.value ? '编辑' : '添加'}${props.pageTitle}`
    );

    const onAdd = () => {
        isEdit.value = false;
        showModel.value = true;
        editData.value = null;
    };
    const onEdit = row => {
        editData.value = row;
        isEdit.value = true;
        showModel.value = true;
    };
    return {
        isEdit,
        editData,
        showModel,
        modelTitle,
        onAdd,
        onEdit
    };
};
